<?php include template("manage_header");?>

<div id="bdw" class="bdw">
<div id="bd" class="cf">
<div id="coupons">
	<div class="dashboard" id="dashboard">
		<ul><?php echo mcurrent_team($selector); ?></ul>
	</div>
    <div id="content" class="coupons-box clear mainwide">
		<div class="box clear">
            <div class="box-top"></div>
            <div class="box-content">
                <div class="head">
				<?php if($selector=='failure'){?>
                    <h2>失败项目</h2>
				<?php } else if($selector=='success') { ?>
                    <h2>成功项目</h2>
				<?php } else { ?>
                    <h2>当前项目</h2>
				<?php }?>
					<ul class="filter">
						<li><form method="get">项目ID：<input type="text" class="h-input" style="width:80px" name="tid" value="<?php echo htmlspecialchars($tid); ?>" >&nbsp;项目名称(模糊)：<input type="text" class="h-input" style="width:230px" name="tname" value="<?php echo htmlspecialchars($tname); ?>" >&nbsp;类型：<select name="gid" style="width:120px;"><?php echo Utility::Option($groupss, $_GET['gid'],'请选择分类'); ?></select>&nbsp;<input type="submit" value="筛选" class="formbutton"  style="padding:1px 6px;"/><form></li>
					</ul>
				</div>
                <div class="sect" style="padding-top:0">
					<table id="orders-list" cellspacing="0" cellpadding="0" border="0" class="coupons-table">
					<tr><th colspan="8"><input type="button" class="formbutton" style="padding:1px 6px;" id="do-checks" value="延期" />  <input type="button" class="formbutton" style="padding:1px 6px;" id="do-checks-addnum" value="加数" /></th></tr>
					<tr><th><input type="checkbox" id="check-team-id"></th><th width="40">ID</th><th width="400">项目名称</th><th width="80" nowrap>类别</th><th width="100">日期</th><th width="50">成交</th><th width="60" nowrap>价格</th><th width="60" nowrap>排序</th><th width="140">操作</th></tr>
					<?php if(is_array($teams)){foreach($teams AS $index=>$one) { ?>
					<?php $oldstate = $one['state']; ?>
					<?php $one['state'] = team_state($one); ?>
					<tr <?php echo $index%2?'':'class="alt"'; ?> id="team-list-id-<?php echo $one['id']; ?>">
						<td><input type="checkbox" id="checkid_<?php echo $one['id']; ?>" name="cbname" value="<?php echo $one['id']; ?>" ></td>
						<td><?php echo $one['id']; ?><br /><a href="/manage/partner/edit.php?id=<?php echo $partners[$one['partner_id']]['id']; ?>"><font size="-1"><?php echo $partners[$one['partner_id']]['title']; ?></font></a></td>
						<td>
							<?php echo $one['team_type']=='normal' ? '[团购]' : ''; ?>
							<?php echo $one['team_type']=='seconds' ? '[秒杀]' : ''; ?>
							<?php echo $one['team_type']=='goods' ? '[商品]' : ''; ?>
							<a class="deal-title" href="http://www.tuan001.com/team.php?id=<?php echo $one['id']; ?>" target="_blank"><?php if($one['short_title']){?><?php echo $one['short_title']; ?><?php } else { ?><?php echo $one['product']; ?><?php }?></a>
						</td>
						<td nowrap><?php echo $cities[$one['city_id']]['name']; ?><br/><?php echo $groups[$one['group_id']]['name']; ?></td>
						<td nowrap><?php echo date('Y-m-d',$one['begin_time']); ?><br/><?php echo date('Y-m-d',$one['end_time']); ?></td>
						<td nowrap><?php echo $one['now_number']; ?>/<?php echo $one['min_number']; ?></td>
						<td nowrap><span class="money"><?php echo $currency; ?></span><?php echo moneyit($one['team_price']); ?><br/><span class="money"><?php echo $currency; ?></span><?php echo moneyit($one['market_price']); ?></td>

						<script type="text/javascript">
							function show_sort_order_input(id){
								spanid = 'sort_order'+id;
								inputid = 'input_sort_order'+id;
								inputtxt = 'input_sort_order_text'+id;
								$("#"+spanid).remove();
								$("#"+inputid).show();
								$("#"+inputtxt).focus();
								$("#"+inputtxt).select();
							}
							function shange_sort_order(id, sort_order){
								return !X.get(WEB_ROOT + '/ajax/manage.php?action=shange_sort_order&id='+id+'&sort_order='+sort_order);
							}
						</script>
						<td><span id="input_sort_order<?php echo $one['id']; ?>" style="display:none"><input id="input_sort_order_text<?php echo $one['id']; ?>" type="text" style="width:40px" value="<?php echo $one['sort_order']; ?>" onblur="shange_sort_order(<?php echo $one['id']; ?>, this.value)" /></span><span id="sort_order<?php echo $one['id']; ?>" ondblclick="show_sort_order_input(<?php echo $one['id']; ?>);"><?php echo $one['sort_order']; ?></span></td>

						<td class="op" nowrap><a href="/ajax/manage.php?action=teamdetail&id=<?php echo $one['id']; ?>" class="ajaxlink">详情</a>｜<a href="/manage/team/edit.php?id=<?php echo $one['id']; ?>">编辑</a>｜<a href="/ajax/manage.php?action=teamremove&id=<?php echo $one['id']; ?>" class="ajaxlink" ask="确定删除本项目吗？" >删除</a><!--{if (in_array($one['state'],array('success','soldout')))}-->｜<a href="/manage/team/down.php?id=<?php echo $one['id']; ?>" target="_blank">下载</a></td>
					</tr>
					<?php }}?>
					<tr><td colspan="9"><?php echo $pagestring; ?></tr>
                    </table>
				</div>
            </div>
            <div class="box-bottom"></div>
        </div>
    </div>
</div>
</div> <!-- bd end -->
</div> <!-- bdw end -->

<script type="text/javascript">
//处理复选框
$(function(){
	$("#check-team-id").click(function(){
		if($("#check-team-id").attr("checked")){
			$("input:checkbox").attr("checked",true);
		}else{
			$("input:checkbox").attr("checked",false);
		}
	});
    //批量延期
	$("#do-checks").click(function(){
		check_val = new Array();
		$("input[name='cbname']:checkbox").each(function(){
			if($(this).attr("checked")){
				check_val.push( $(this).val());
			}
		});
		if(check_val == ''){
			alert("没有选中任何项目！");
			return false;
		}else{
			return !X.get(WEB_ROOT + '/ajax/manage.php?action=extension_team&ids='+check_val);
		}
		//alert("http://www.51uutuan.com/index.php?id="+check_val);
	});
    //批量加数
    $("#do-checks-addnum").click(function(){
		check_val = new Array();
		$("input[name='cbname']:checkbox").each(function(){
			if($(this).attr("checked")){
				check_val.push( $(this).val());
			}
		});
		if(check_val == ''){
			alert("没有选中任何项目！");
			return false;
		}else{
			return !X.get(WEB_ROOT + '/ajax/manage.php?action=add_pre_num&ids='+check_val);
		}
		//alert("http://www.51uutuan.com/index.php?id="+check_val);
	});
    
})
</script>

<?php include template("manage_footer");?>
